package san;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

// @Component就是组件扫描保存到Spring容器的关键注解之一
// Component是组件的意思,当前类被扫描时,会自动实例化一个对象,
// 保存到Spring容器,对象的id(名称)为当前类名首字母小写的单词guanYu

@Component
//@Controller
//@Service
//@Repository

//组件扫描方式配置原型作用域
//@Scope("prototype")
//@Lazy
public class GuanYu {

    private String name="关羽";

    @Autowired
    private DragonBlade dragonBlade;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public DragonBlade getDragonBlade() {
        return dragonBlade;
    }

    public void setDragonBlade(DragonBlade dragonBlade) {
        this.dragonBlade = dragonBlade;
    }

    public void fight(){
        System.out.println(name+"使用"+dragonBlade+"战斗!");
    }



}
